<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        var s = "aac"
        var lengthOfLongestSubstring = function (s) {
            var num = 0;
            var arr = [];
            if (s.length == 1) {
                return 1;
            } else {
                for (let i = 0; i < s.length; i++) {
                    var a = "";
                    for (let k = i; k < s.length; k++) {
                        if (!a.includes(s[k])) {
                            a = a + s[k];
                            console.log(a);
                            if(k==s.length-1){
                                arr.push(a)
                                break
                            }
                        } else{
                            arr.push(a)
                            break
                        }
                    }
                }
                arr.forEach(res => {
                    if (res.length > num) {
                        num = res.length;
                    }
                })
                console.log(arr)
                return num
            }
        };
        console.log(lengthOfLongestSubstring(s));
    </script>
</body>

</html>